package com.pe1n.yangtaopai.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.pe1n.yangtaopai.R;
import com.pe1n.yangtaopai.bean.BrandBean;
import com.pe1n.yangtaopai.bean.TypeBean;
import com.pe1n.yangtaopai.view.activity.ItemOneListActivity;

import java.util.List;

/**
 * Created by Pe1n on 2016/11/23.
 */

public class MyBrandAdapter extends RecyclerView.Adapter<MyBrandAdapter.MyViewHolder> {

    private Context mContext;
    private List<BrandBean.DataBean> mList;

    public MyBrandAdapter(Context mContext, List<BrandBean.DataBean> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.inner_item_brand_layout,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        String imgUrl = mList.get(position).getImagePath();
        Glide.with(mContext).load(imgUrl).placeholder(R.drawable.place_holder).into(holder.imageView);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent  = new Intent(mContext, ItemOneListActivity.class);
                intent.putExtra("OneImgTitle",mList.get(position).getTitle());
                intent.putExtra("ID",mList.get(position).getTargetId());
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

        private ImageView imageView;

        public MyViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.iv_inner_brand);
        }
    }

}
